Increase Connection Pool Limit to Avoid Resource Exhaustion #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current HTTP transport limits the idle connections for pooling to 2 (
MaxIdleConns
is unlimited butMaxIdleConnsPerHost
isDefaultMaxIdleConnsPerHost=2
) . In the default configuration,monsoon
will already do 5 concurrent requests which causes the limit to be exceeded and connections to be closed and reopened unnecessarily.As this closing and reopening keeps happening over the lifetime of the scan, the operating system will keep the ephemeral ports of the countless closed connections in a
TIME_WAIT
state for some time. This can then easily cause the system to accumulate ports in this state until it exceeds its limits (on macOS this causes the errorcan't assign requested address
).This PR sets
MaxIdleConnsPerHost
andDefaultMaxIdleConnsPerHost
to 100. The same solution was already applied togobuster
(see OJ/gobuster#127 and OJ/gobuster#140). The problem is also described in detail in this blog post, which suggests the same solution.Another solution would be to take the number of "threads" as an argument and set it as the limit. This is what https://github.com/rakyll/hey does.